import React, { Component } from 'react'
export default class App extends Component {
  state = {
    firstName: '',
    lastName: ''
  }
  handler = (event) => {
    console.log(event.target.name)
    this.setState({ // 如果对象的key值为变量，使用[变量]形式
      [event.target.name]: event.target.value
    })
    // oDiv.style.display = 'flex'
    // oDiv.style['display'] = 'flex'
  }
  render() {
    return (
      <div>
        <input name="firstName" onChange = { this.handler } type="text" placeholder="姓"/> + 
        <input name="lastName" onChange = { this.handler } type="text" placeholder="名"/> = 
        {
          this.state.firstName + ' ' + this.state.lastName
        }
      </div>
    )
  }
}
